<template>
  <div class="itemAdd">
    <el-form :model="item" :rules="rules" ref="itemAdd" label-width="100px" class="demo-ruleForm">
			<el-form-item label="商品名称" prop="name">
			<el-input v-model="item.name"></el-input>
		</el-form-item>
		<el-form-item label="商品价格" prop="price">
			<el-input v-model="item.price"></el-input>
		</el-form-item>
		<el-form-item label="商品分类" prop="cateId">
			<el-select v-model="item.cataId" placeholder="请选择所属分类">
				<el-option
				v-for="cata in catas"
				:key="cata.id"
				:label="cata.cataName"
				:value="cata.cataId"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="是否上架">
			 <el-switch
            v-model="item.onsale"
            :active-value="1"
            :inactive-value="0"></el-switch>
		</el-form-item>
		<el-form-item label="商品描述" prop="item.desc">
			<el-input type="textarea" v-model="ruleForm.desc"></el-input>
		</el-form-item>
		<el-form-item>
			<el-button type="primary" @click="submitForm()">立即增加</el-button>
			<el-button>取消</el-button>
		</el-form-item>
	</el-form>

  </div>
</template>

<script>
import { getCataLists }
export default {
  data () {
    return {
      item: {
        name: '',
        price: 0,
        cateId: -1,
        desc: '',
        thumb: '',
        onsale: 1,
        content: ''
      },
			catas: []
    }
  },
	methods: {
		getCates () {
      getCateLists().then((res) => {
        if (res.data.code === 200) {
          this.cates = res.data.data.lists
        }
      })
    }
  },
  created () {
    this.getCates()
  }

</script>


<style lang="scss" scoped>

</style>
